package com.beney.dao;

import com.beney.pojo.User;
import com.beney.util.db.FileInUtil;
import com.beney.util.db.FileOutUtil;

import java.util.Set;

/**
 * 用户访问对象
 *
 * @author Beney
 */
public class UserDaoFileImpl implements UserDao {
    private User user;

    @Override
    public Set<Integer> getUserGeneratedQuesCodes() {
        return FileInUtil.readAllQuesCodeFromUser(user.getName());
    }

    @Override
    public String saveTestPaper(StringBuilder[] questions) {
        return FileOutUtil.saveQuesToUserFolder(
                user.getName(),
                questions
        );
    }

    @Override
    public void setIdentity(String identity) {
        user.setIdentity(identity);
    }

    @Override
    public String getIdentity() {
        return user.GetIdentity();
    }

    @Override
    public String getName()
    {
        return user.getName();
    }

    @Override
    public void setAccessTo(User user) {
        this.user = user;
    }
}
